import 'dart:convert';

T? asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class LoginResponse {
  LoginResponse({
    this.token,
    this.userInfo,
  });

  factory LoginResponse.fromJson(Map<String, dynamic> jsonRes) => LoginResponse(
        token: jsonRes['token'] == null ? null : Token.fromJson(asT<Map<String, dynamic>>(jsonRes['token'])!),
        userInfo:
            jsonRes['userInfo'] == null ? null : UserInfo.fromJson(asT<Map<String, dynamic>>(jsonRes['userInfo'])!),
      );

  Token? token;
  UserInfo? userInfo;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'token': token,
        'userInfo': userInfo,
      };

  LoginResponse clone() => LoginResponse.fromJson(asT<Map<String, dynamic>>(jsonDecode(jsonEncode(this)))!);
}

class Token {
  Token({
    this.expire,
    this.token,
  });

  factory Token.fromJson(Map<String, dynamic> jsonRes) => Token(
        expire: asT<int?>(jsonRes['expire']),
        token: asT<String?>(jsonRes['token']),
      );

  int? expire;
  String? token;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'expire': expire,
        'token': token,
      };

  Token clone() => Token.fromJson(asT<Map<String, dynamic>>(jsonDecode(jsonEncode(this)))!);
}

class UserInfo {
  UserInfo({
    this.createEmp,
    this.createTime,
    this.empEmail,
    this.empMobile,
    this.empName,
    this.empNo,
    this.empPhone,
    this.empSex,
    this.enabled,
    this.id,
    this.orgId,
    this.orgName,
    this.positionId,
    this.positionName,
    this.roleId,
    this.roleName,
    this.updateEmp,
    this.updateTime,
    this.userName,
    this.userPwd,
  });

  factory UserInfo.fromJson(Map<String, dynamic> jsonRes) => UserInfo(
        createEmp: asT<String?>(jsonRes['createEmp']),
        createTime: asT<String?>(jsonRes['createTime']),
        empEmail: asT<String?>(jsonRes['empEmail']),
        empMobile: asT<String?>(jsonRes['empMobile']),
        empName: asT<String?>(jsonRes['empName']),
        empNo: asT<String?>(jsonRes['empNo']),
        empPhone: asT<String?>(jsonRes['empPhone']),
        empSex: asT<String?>(jsonRes['empSex']),
        enabled: asT<int?>(jsonRes['enabled']),
        id: asT<int?>(jsonRes['id']),
        orgId: asT<int?>(jsonRes['orgId']),
        orgName: asT<String?>(jsonRes['orgName']),
        positionId: asT<int?>(jsonRes['positionId']),
        positionName: asT<String?>(jsonRes['positionName']),
        roleId: asT<int?>(jsonRes['roleId']),
        roleName: asT<String?>(jsonRes['roleName']),
        updateEmp: asT<String?>(jsonRes['updateEmp']),
        updateTime: asT<String?>(jsonRes['updateTime']),
        userName: asT<String?>(jsonRes['userName']),
        userPwd: asT<Object?>(jsonRes['userPwd']),
      );

  String? createEmp;
  String? createTime;
  String? empEmail;
  String? empMobile;
  String? empName;
  String? empNo;
  String? empPhone;
  String? empSex;
  int? enabled;
  int? id;
  int? orgId;
  String? orgName;
  int? positionId;
  String? positionName;
  int? roleId;
  String? roleName;
  String? updateEmp;
  String? updateTime;
  String? userName;
  Object? userPwd;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'createEmp': createEmp,
        'createTime': createTime,
        'empEmail': empEmail,
        'empMobile': empMobile,
        'empName': empName,
        'empNo': empNo,
        'empPhone': empPhone,
        'empSex': empSex,
        'enabled': enabled,
        'id': id,
        'orgId': orgId,
        'orgName': orgName,
        'positionId': positionId,
        'positionName': positionName,
        'roleId': roleId,
        'roleName': roleName,
        'updateEmp': updateEmp,
        'updateTime': updateTime,
        'userName': userName,
        'userPwd': userPwd,
      };

  UserInfo clone() => UserInfo.fromJson(asT<Map<String, dynamic>>(jsonDecode(jsonEncode(this)))!);
}
